<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017-7-13
 * Time: 16:17
 */

namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;
use think\Validate;

class OrderController extends AdminBaseController
{

    public function index()
    {
        $param    = $this->request->param();
        $o_number = isset($param['o_number']) ? $param['o_number'] : '';
        $where = null;
        if($o_number){ $where['o.o_number'] = ['like', "%$o_number%"];}else{ unset($param['o_number']);}
        $order = Db::name('order')->field('o.id,o.o_number,ud.u_nickname,o.o_money,o.o_amount,o.o_type,o.o_status,o.o_description,o.o_createtime')
            ->alias('o')
            ->join('users_detail ud','o.o_udid = ud.id')
            ->where($where)
            ->order(['o.id' => 'DESC'])
            ->paginate(20);
        $order->appends($param);
        $page = $order->render();
        $this->assign("o_number", $o_number);
        $this->assign("order", $order);
        $this->assign("page", $page);
        return $this->fetch();
    }
}